package org.jeecg.modules.wms.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.wms.entity.WmsPurchaseOrderDetail;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Description: 采购单明细表Mapper接口
 * @Author: jeecg-boot
 * @Date: 2023-07-17
 * @Version: V1.0
 */
public interface WmsPurchaseOrderDetailMapper extends BaseMapper<WmsPurchaseOrderDetail> {

    /**
     * 根据采购单ID查询明细列表
     *
     * @param purchaseOrderId 采购单ID
     * @return 明细列表
     */
    List<WmsPurchaseOrderDetail> selectByPurchaseOrderId(@Param("purchaseOrderId") String purchaseOrderId);

    /**
     * 根据采购单ID删除明细
     *
     * @param purchaseOrderId 采购单ID
     * @return 删除结果
     */
    int deleteByPurchaseOrderId(@Param("purchaseOrderId") String purchaseOrderId);

    /**
     * 更新已入库数量
     *
     * @param id               明细ID
     * @param receivedQuantity 已入库数量
     * @return 更新结果
     */
    int updateReceivedQuantity(@Param("id") String id, @Param("receivedQuantity") BigDecimal receivedQuantity);

    /**
     * 批量删除明细
     *
     * @param ids ID列表
     * @return 删除结果
     */
    int deleteBatchByIds(@Param("ids") List<String> ids);

    /**
     * 根据物料编码查询最近的采购单明细
     *
     * @param materialCode 物料编码
     * @param limit        限制条数
     * @return 采购单明细列表
     */
    List<WmsPurchaseOrderDetail> selectLatestByMaterialCode(@Param("materialCode") String materialCode, @Param("limit") int limit);
} 